import os

from src.preprocess import preprocess
from src.label import process_label
from src.dataset import transImage2Mind
from src.config import config as args


if __name__ == '__main__':
    if not os.path.exists(os.path.join(args.data_dir, args.train_image_dir_name)):
        print('{} doesn\'t exist'.format(os.path.join(args.data_dir, args.train_image_dir_name)))
        preprocess()
        process_label()
    if not os.path.exists(os.path.join(args.data_dir, args.mindsrecord_train_file)):
        print('{} doesn\'t exist'.format(os.path.join(args.data_dir, args.mindsrecord_train_file)))
        transImage2Mind(os.path.join(args.data_dir, args.mindsrecord_train_file))
    if not os.path.exists(os.path.join(args.data_dir, args.mindsrecord_test_file)):
        print('{} doesn\'t exist'.format(os.path.join(args.data_dir, args.mindsrecord_test_file)))
        transImage2Mind(os.path.join(args.data_dir, args.mindsrecord_test_file), is_val=True)

    print('Mindrecord exists.')
